<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>LMB-SVN - 用户登录</title>
		<link rel="stylesheet" href="${httpRootPath}/resources/BeginnerAdmin/plugins/layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="${httpRootPath}/resources/BeginnerAdmin/css/login.css" />
		<script type="text/javascript" src="${httpRootPath}/resources/main/js/jquery-1.9.1.min.js"></script>
		<script type="text/javascript" src="${httpRootPath}/resources/main/js/jquery.form.js"></script>
		<script type="text/javascript" src="${httpRootPath}/resources/layer/layer.js"></script>
	</head>
	<body class="beg-login-bg">
		<div class="beg-login-box">
			<header>
				<h1>用户登录</h1>
			</header>
			<div class="beg-login-main">
				<form id="loginform" action="/login.do" class="layui-form" method="post">
					<div class="layui-form-item">
						<label class="beg-login-icon">
                        	<i class="layui-icon">&#xe612;</i>
                    	</label>
						<input type="text" id="username" name="Loginname" lay-verify="required" autocomplete="off" placeholder="这里输入登录名" class="layui-input">
					</div>
					<div class="layui-form-item">
						<label class="beg-login-icon">
                        	<i class="layui-icon">&#xe642;</i>
                    	</label>
						<input type="password" id="password" name="Password" lay-verify="required" autocomplete="off" placeholder="这里输入密码" class="layui-input">
					</div>
					<div class="layui-form-item">
						<label class="beg-login-icon">
							<i class="layui-icon">&#xe647;</i>
						</label>
						<input type="text" id="captcha" name="Captcha" lay-verify="required" autocomplete="off" placeholder="这里输入验证码" class="layui-input" style="width: 180px;display:inline;">
						<img id="captchaimg" src="${httpRootPath}/captcha/captcha-image.htm" style="width: 83px; height: 35px;margin-top: -2px;" alt="看不清？点击刷新。" onclick="reloadImg();"/>
					</div>
					<div class="layui-form-item">
						<input class="layui-btn" style="width: 100%" type="button" value="登录" onclick="loginsubmit();"/>
						<div class="beg-clear"></div>
					</div>
				</form>
			</div>
			<footer>
				<p>copyright © 2017-2018 www.lzfsd.com</p>
			</footer>
		</div>
		<script type="text/javascript" src="${httpRootPath}/resources/BeginnerAdmin/plugins/layui/layui.js"></script>
		<script>
			layui.use(['layer', 'form'], function() {
				var layer = layui.layer,
					$ = layui.jquery,
					form = layui.form();
					
				form.on('submit(login)',function(data){
					
					location.href='index.html';
					return false;
				});
			});

			function reloadImg(){
				$("#captchaimg").attr("src", "${httpRootPath}/captcha/captcha-image.htm?time="+Math.random());
			}

			function loginsubmit(){
                var username = $("#username").val();
                var password = $("#password").val();
                var captcha = $("#captcha").val();

                if(username == null || username == ""){
                    $("#username").focus();
                    layer.tips('请输入用户名', '#username');
                    return;
                }
                if(password == null || password == ""){
                    $("#password").focus();
                    layer.tips('请输入密码', '#password');
                    return;
                }
                if(captcha == null || captcha == ""){
                    $("#captcha").focus();
                    layer.tips('请输入验证码', '#captcha');
                    return;
                }
                $('#loginform').ajaxSubmit({
                    dataType:'html',
                    timeout:0,
                    success:showResponse,
                    error:showError
                });// 提交表单
			}



            function showResponse(json){
                var obj = $.parseJSON(json);
                var code = obj.code;
                var msg = obj.msg;
                if(code == 0){
                    window.location.href = "index.htm";
                }else{
                    $("#captchaimg").attr("src", "${httpRootPath}/captcha/captcha-image.htm?time="+Math.random());
                    layer.alert(msg)
                }
            }
            function showError(xhr, ajaxOptions, thrownError) {
                layer.alert('网络异常')
            }
		</script>
	</body>

</html>